package com.punai.customer.controller;

import com.punai.common.core.controller.BaseController;
import com.punai.common.core.domain.AjaxResult;
import com.punai.common.core.domain.TreeBo;
import com.punai.common.core.page.TableDataInfo;
import com.punai.customer.domain.CusVersionsDiscrepancy;
import com.punai.customer.domain.bo.ChangeGxListBo;
import com.punai.customer.domain.contants.CusConstants;
import com.punai.customer.domain.vo.AddSupLinkFbGxVo;
import com.punai.customer.domain.vo.CusFbVo;
import com.punai.customer.service.ICusVersionsDiscrepancyService;
import com.punai.customer.service.IFBSupportService;
import com.punai.standard.domain.vo.StaFeeVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/cus/sup/")
public class CusGxFbSupportController extends BaseController {

    @Autowired
    private IFBSupportService fbSupportService;
    @Autowired
    private ICusVersionsDiscrepancyService cusVersionsDiscrepancyService;

    @GetMapping("/gxList")
    public TableDataInfo assetSubpkList(CusFbVo vo) {
        TableDataInfo tableDataInfo = fbSupportService.getGxList(vo);
        return tableDataInfo;
    }

    @PostMapping("/addSupLinkFbGx")
    public AjaxResult addSupLinkFbGx(@RequestBody AddSupLinkFbGxVo vo) {
        return toAjax(fbSupportService.insertSupLinkFbGx(vo));
    }

    @GetMapping("/changeGxList/{versionId}/{fbId}/{gxIds}")
    public AjaxResult changeGxList(@PathVariable String versionId,@PathVariable String fbId,@PathVariable String gxIds) {
        ChangeGxListBo changeGxListBo = fbSupportService.changeGxList(versionId,fbId,gxIds,getCompanyId());
        return AjaxResult.success(changeGxListBo);
    }

    @GetMapping("/treeDataByTopId/{topId}")
    public AjaxResult gxTreeData(@PathVariable String topId)
    {
        List<TreeBo> list = fbSupportService.treeDataByTopId(topId,getCompanyId());
        return AjaxResult.success(list);
    }

    @GetMapping("/getGxList")
    public TableDataInfo gxList(StaFeeVo vo)
    {
        TableDataInfo list = fbSupportService.getFeeListOnFb(vo,getCompanyId());
        return list;
    }

    @GetMapping("/getContrastData")
    public TableDataInfo getDataLog(CusVersionsDiscrepancy cusVersionsDiscrepancy) {
        startPage();
        cusVersionsDiscrepancy.setCompanyId(getCompanyId());
        cusVersionsDiscrepancy.setPublishType(CusConstants.FB_TYPE);
        return getDataTable(cusVersionsDiscrepancyService.selectStaVersionsDiscrepancyList(cusVersionsDiscrepancy));
    }
}
